<!DOCTYPE html>
<html xmlns:layout="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
	layout:decorate="~{common/layoutTeacher}">

<head>
	<meta charset="UTF-8">
	<title>留言反馈</title>
</head>

<body>
	<div layout:fragment="fragment_body">
		<el-row :gutter="20">
			<el-col :span="24">
				<el-button type="primary" @click="openRaceFeedback(null)">我要留言反馈</el-button>
				<el-table :data="raceFeedbacks" border highlight-current-row style="width: 100%">
					<!-- -->
					<!--<el-table-column prop="feedbackUserId" label="反馈人"></el-table-column>-->
					<el-table-column prop="feedbackContent" label="反馈内容"></el-table-column>
					<el-table-column prop="feedbackReply" label="回复"></el-table-column>
					<el-table-column prop="feedbackTime" label="反馈时间"></el-table-column>
					<el-table-column prop="feedbackReplyTime" label="回复时间"></el-table-column>
					<el-table-column label="操作" width="160px">
						<template slot-scope="scope">
							<!--<el-button @click="openRaceFeedback(scope.row)" type="text" size="small">修 改</el-button>-->
							<el-popconfirm v-show="scope.row.feedbackReply == null" title="是否删除？" @confirm="delRaceFeedback(scope.row.feedbackId)">
								<el-button slot="reference" type="text" size="small">删 除</el-button>
							</el-popconfirm>
						</template>
					</el-table-column>
				</el-table>
			</el-col>
		</el-row>
		<!--弹框-->
		<el-dialog :title="raceFeedbackForm.ttitle" :visible.sync="raceFeedbackForm.visible" width="30%">
			<el-form :model="raceFeedbackForm" :rules="raceFeedbackRules" ref="raceFeedbackForm" label-width="100px">
				<!-- -->
				<!--<el-form-item label="反馈人" prop="feedbackUserId">
					<el-input v-model="raceFeedbackForm.feedbackUserId"></el-input>
				</el-form-item>-->
				<el-form-item label="反馈内容" prop="feedbackContent">
					<el-input v-model="raceFeedbackForm.feedbackContent"></el-input>
				</el-form-item>
				<!--<el-form-item label="回复" prop="feedbackReply">
					<el-input v-model="raceFeedbackForm.feedbackReply"></el-input>
				</el-form-item>
				<el-form-item label="反馈时间" prop="feedbackTime">
					<el-input v-model="raceFeedbackForm.feedbackTime"></el-input>
				</el-form-item>
				<el-form-item label="回复时间" prop="feedbackReplyTime">
					<el-input v-model="raceFeedbackForm.feedbackReplyTime"></el-input>
				</el-form-item>-->
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeRaceFeedback">取 消</el-button>
				<el-button type="primary" @click="saveRaceFeedback">保 存</el-button>
			</span>
		</el-dialog>
	</div>
</body>
<script type="text/javascript" layout:fragment="fragment_script">
	let vueData = {
		raceFeedbacks: [],
		selectRaceFeedback: null,
		raceFeedbackForm: {
			visible: false,
			ttitle: '新增/修改',
			feedbackId : '',
			feedbackUserId : '',
			feedbackContent : '',
			feedbackReply : '',
			feedbackTime : '',
			feedbackReplyTime : '',
		},
		raceFeedbackQuery: {
			page: '',
			size: '',
		},
		raceFeedbackRules: {
			feedbackContent: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
		},
	}
	let vueMethods = {
		getRaceFeedbacks() {
			let that = this
			postRequst('/getFeedbacks', that.raceFeedbackQuery, true).then(function (resp) {
				that.raceFeedbacks = resp.rows
				if (resp.rows && resp.rows.length > 0) {
					that.selectRaceFeedback = resp.rows[0]
				}
			})
		},
		openRaceFeedback(row) {
			let that = this
			if (row) {
				that.raceFeedbackForm.ttitle = '修改'
				that.raceFeedbackForm.feedbackId = row.feedbackId
				that.raceFeedbackForm.feedbackUserId = row.feedbackUserId
				that.raceFeedbackForm.feedbackContent = row.feedbackContent
				that.raceFeedbackForm.feedbackReply = row.feedbackReply
				//that.raceFeedbackForm.feedbackTime = row.feedbackTime
				//that.raceFeedbackForm.feedbackReplyTime = row.feedbackReplyTime
			} else {
				that.raceFeedbackForm.ttitle = '新增'
				that.raceFeedbackForm.feedbackId = ''
				that.raceFeedbackForm.feedbackUserId = ''
				that.raceFeedbackForm.feedbackContent = ''
				that.raceFeedbackForm.feedbackReply = ''
				//that.raceFeedbackForm.feedbackTime = ''
				//that.raceFeedbackForm.feedbackReplyTime = ''
			}
			that.raceFeedbackForm.visible = true
		},
		closeRaceFeedback() {
			this.$refs["raceFeedbackForm"].resetFields();
			this.raceFeedbackForm.visible = false
		},
		saveRaceFeedback() {
			let that = this
			this.$refs["raceFeedbackForm"].validate((valid) => {
				if (valid) {
					postRequst('/createFeedback', that.raceFeedbackForm, true).then(function (resp) {
						if (resp.status == 0) {
							that.getRaceFeedbacks()
							that.raceFeedbackForm.visible = false
							that.$message({message: resp.msg, type: "success"});
						} else {
							that.$message({message: resp.msg, type: "error"});
						}
					})
				}
			});
		},
		delRaceFeedback(feedbackId) {
			let that = this
			postRequst('/delFeedback', {feedbackId: feedbackId}, true).then(function (resp) {
				if (resp.status == 0) {
					that.getRaceFeedbacks()
					that.$message({message: resp.msg, type: "success"});
				} else {
					that.$message({message: resp.msg, type: "error"});
				}
			})
		},
	}
	function vueCreated() {
		let that = this
		that.getRaceFeedbacks()
	}
</script>

</html>